package com.costaccounting.web.controller.feesys;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.costaccounting.common.annotation.Log;
import com.costaccounting.common.core.controller.BaseController;
import com.costaccounting.common.core.domain.AjaxResult;
import com.costaccounting.common.enums.BusinessType;
import com.costaccounting.feesys.domain.ZsCategoryPercentage;
import com.costaccounting.feesys.service.IZsCategoryPercentageService;
import com.costaccounting.common.utils.poi.ExcelUtil;
import com.costaccounting.common.core.page.TableDataInfo;

/**
 * 分类占比Controller
 * 
 * @author ruoyi
 * @date 2021-11-26
 */
@RestController
@RequestMapping("/feesys/percentageinfo")
public class ZsCategoryPercentageController extends BaseController
{
    @Autowired
    private IZsCategoryPercentageService zsCategoryPercentageService;

    /**
     * 查询分类占比列表
     */
    @PreAuthorize("@ss.hasPermi('feesys:percentageinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(ZsCategoryPercentage zsCategoryPercentage)
    {
        startPage();
        List<ZsCategoryPercentage> list = zsCategoryPercentageService.selectZsCategoryPercentageList(zsCategoryPercentage);
        return getDataTable(list);
    }

    /**
     * 导出分类占比列表
     */
    @PreAuthorize("@ss.hasPermi('feesys:percentageinfo:export')")
    @Log(title = "分类占比", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ZsCategoryPercentage zsCategoryPercentage)
    {
        List<ZsCategoryPercentage> list = zsCategoryPercentageService.selectZsCategoryPercentageList(zsCategoryPercentage);
        ExcelUtil<ZsCategoryPercentage> util = new ExcelUtil<ZsCategoryPercentage>(ZsCategoryPercentage.class);
        return util.exportExcel(list, "分类占比数据");
    }

    /**
     * 获取分类占比详细信息
     */
    @PreAuthorize("@ss.hasPermi('feesys:percentageinfo:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(zsCategoryPercentageService.selectZsCategoryPercentageById(id));
    }

    /**
     * 新增分类占比
     */
    @PreAuthorize("@ss.hasPermi('feesys:percentageinfo:add')")
    @Log(title = "分类占比", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ZsCategoryPercentage zsCategoryPercentage)
    {
        return toAjax(zsCategoryPercentageService.insertZsCategoryPercentage(zsCategoryPercentage));
    }

    /**
     * 修改分类占比
     */
    @PreAuthorize("@ss.hasPermi('feesys:percentageinfo:edit')")
    @Log(title = "分类占比", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ZsCategoryPercentage zsCategoryPercentage)
    {
        return toAjax(zsCategoryPercentageService.updateZsCategoryPercentage(zsCategoryPercentage));
    }

    /**
     * 删除分类占比
     */
    @PreAuthorize("@ss.hasPermi('feesys:percentageinfo:remove')")
    @Log(title = "分类占比", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(zsCategoryPercentageService.deleteZsCategoryPercentageByIds(ids));
    }
}
